package org.poem.exception.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@AllArgsConstructor
@Getter
public enum KeeperEnums {

    NO_NODE("节点不存在", "NO_NODE"),
    ACTION_Interrupted("操作被打断","INTERRUPTED"),
    ZK_BAD_VERSION("节点版本不正确","ZK_BAD_VERSION"),
    ZK_NODE_EXISTS("节点已存在", "ZK_NODE_EXISTS");

    private String name;
    private String code;

    public static String getNameByCode(String code) {
        for (KeeperEnums value : KeeperEnums.values()) {
            if (Objects.equals(value.code, code)) {
                return value.name;
            }
        }
        return "";
    }
    }
